package com.bgs.travelapp.scenicRank.mapper;

import com.bgs.travelapp.mapper.BaseMapper;
import com.bgs.travelapp.scenicRank.entity.ScenicRankEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ScenicRankMapper extends BaseMapper<ScenicRankEntity> {
    //修改景区排行版中出行的次数
    @Update("update scenic_rank set travel_volume =#{ticketSum}  where scenic_id = #{scenicId}")
    int updateScenicTraveQuantity(Integer scenicId,Integer ticketSum);

    //修改景区排行中收藏景区的次数
    @Update("update scenic_rank set collection=#{collection} where scenic_id =#{id} ")
    int updateScenicCollection(Integer collection, Integer id);

    //查询景区收藏排行
    @Select("select * from scenic_rank order by collection desc limit 0,5")
    @Results(
            {@Result(property = "scenicName",column = "scenic_name"),
                    @Result(property = "travelVolume",column = "travel_volume"),
                    @Result(property = "scenicId",column = "scenic_id"),
                    @Result(property = "scenicAvatarId",column = "scenic_avatar_id"),
                    @Result(property = "scenicPrice",column = "scenic_price"),
            }
    )
    List<ScenicRankEntity> selectScenicRankCollection();

    //查询景区出行排行
    @Select("select * from scenic_rank order by travel_volume desc limit 0,5")
    @Results(
            {@Result(property = "scenicName",column = "scenic_name"),
                    @Result(property = "travelVolume",column = "travel_volume"),
                    @Result(property = "scenicId",column = "scenic_id"),
                    @Result(property = "scenicAvatarId",column = "scenic_avatar_id"),
                    @Result(property = "scenicPrice",column = "scenic_price"),
            }
    )
    List<ScenicRankEntity> selectScenicRankTravelVolume();

}
